package com.lkd.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lkd.base.ResponseResult;
import com.lkd.domain.Node;
import com.lkd.domain.Partner;
import com.lkd.domain.Region;
import com.lkd.pageParam.PartnerPageParam;
import com.lkd.pageParam.RegionPageParam;
import com.lkd.service.IRegionService;
import com.lkd.vo.RegionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.lkd.base.ResponseResult.success;

/**
 * <p>
 * 运营区域 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-02-09
 */
@RestController
@Api("区域相关接口")
@RequestMapping("/api/vm-service/region")
public class RegionController {
    @Autowired
    private IRegionService regionService;
    @ApiOperation("区域搜索")
    @GetMapping("/search")
    public ResponseResult<Page<RegionVo>> search(RegionPageParam param){
        Page<RegionVo> page =  regionService.getPage(param);
        return success(page);
    }
    @PostMapping
    @ApiOperation("新增区域")
    public ResponseResult add(@RequestBody Region region){
        regionService.save(region);
        return success();
    }
    @PutMapping("/regionId")
    @ApiOperation("新增区域")
    public ResponseResult update(@RequestBody Region region,@PathVariable Long regionId){
        region.setId(regionId);
        regionService.updateById(region);
        return success();
    }
    @DeleteMapping("/{regionId}")
    @ApiOperation("新增区域")
    public ResponseResult delete(@PathVariable Long regionId){

        regionService.removeById(regionId);
        return success();
    }

}
